package com.office.dates.controller;

import com.office.common.core.domain.AjaxResult;
import com.office.dates.domain.Dates;
import com.office.dates.server.DatesServer;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: 柒月
 * @date: 2025/6/26 下午3:45
 * @version: 1.0
 */

@RestController
@RequestMapping("/date")
public class DatesController {

    @Resource
    private DatesServer datesServer;

    @GetMapping("/view")
    public AjaxResult view(@RequestParam String today) {
        List<Dates> dates = datesServer.getDatesToDay(today);
        return AjaxResult.success(dates);
    }

    @PostMapping("/add")
    public AjaxResult add(@RequestBody Dates dates) {
        datesServer.addDate(dates);
        return AjaxResult.success();
    }

    /**
     *
     * @return 获取全部的日程信息
     */
    @GetMapping("/all")
    public AjaxResult all() {
        List<Dates> list = datesServer.getDatesAll();
        return AjaxResult.success(list);
    }

    /**
     *
     * @return 今天的日程
     */
    @GetMapping("/today")
    public AjaxResult today() {
        List<Dates> list = datesServer.getDatesToTheDay();
        return AjaxResult.success(list);
     }

    /**
     *
     * @return 获取用户的会议数和总数
     */
    @GetMapping("/count")
    public AjaxResult count() {
        Dates dates = datesServer.getDateCount();
        return AjaxResult.success(dates);
    }

}
